package ch7.test2;

import java.util.Scanner;

public interface Fruit {
	
}
class Apple implements Fruit{
	public Apple () {
		System.out.println("创建了一个苹果对象");
	}
}
class Banana implements Fruit {
	public Banana() {
		System.out.println("创建一个香蕉对象");
	}
}
class Grape implements Fruit{
	public Grape() {
		System.out.println("创建一个葡萄对象");
	}
}
 class Gardener{
	 public Fruit create() {
		 Scanner input = new Scanner(System.in);
		 String name = input.next();
		 
		 Fruit fruit = null;
		 switch (name) {
		case "苹果":
			fruit = new Apple();
			break;
		case "香蕉":
			fruit = new Banana();
			break;
		case "葡萄":
			fruit = new Grape();
			break;
		}
		 input.close();
		 return fruit;
	 }
 }